Change in openvpn[master]: Ensure that the AF_UNIX socket pair has at least 65k of buffer space
A message that is not in the archive (sent off-list or not yet received): gerrit.1726754803000.Ice015df81543c01094479929f0cb3075ca4f3813@...2715...
Attention is currently required from: flichtenheld.
Hello flichtenheld,
I'd like you to do a code review.
Please visit
http://gerrit.openvpn.net/c/openvpn/+/754?usp=email
to review the following change.
Change subject: Ensure that the AF_UNIX socket pair has at least 65k of buffer space
......................................................................
Ensure that the AF_UNIX socket pair has at least 65k of buffer space
Without this change, pinging a lwipovpn client with something like a 3000 byte payload on macOS often fails as the default buffer sizes on macOS are 2048 for send and 4096 for receive.
---
M src/openvpn/socket.c
M src/openvpn/socket.h
M src/openvpn/tun_afunix.c
3 files changed, 29 insertions(+), 6 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/54/754/1
src/openvpn/socket.c +9 -6
@@ -890,20 +890,23 @@#endif } -static void -socket_set_buffers (socket_descriptor_t fd,const struct socket_buffer_size *sbs) +void +socket_set_buffers (socket_descriptor_t fd,const struct socket_buffer_size *sbs, +bool reduce_size) {if (sbs) {const int sndbuf_old =socket_get_sndbuf (fd);const int rcvbuf_old =socket_get_rcvbuf (fd); -if (sbs->sndbuf) +if (sbs->sndbuf + && (reduce_size || sndbuf_old < sbs->sndbuf)) {socket_set_sndbuf (fd, sbs->sndbuf); } -if (sbs->rcvbuf) +if (sbs->rcvbuf + && (reduce_size || rcvbuf_old < sbs->rcvbuf)) {socket_set_rcvbuf (fd, sbs->rcvbuf); }
@@ -986,7 +989,7 @@ { ls->socket_buffer_sizes.sndbuf = sndbuf; ls->socket_buffer_sizes.rcvbuf = rcvbuf; -socket_set_buffers (ls->sd, &ls->socket_buffer_sizes); +socket_set_buffers (ls->sd, &ls->socket_buffer_sizes, true); } }
@@ -1136,7 +1139,7 @@ sock->info.af = addr->ai_family;/* set socket buffers based on --sndbuf and --rcvbuf options */ -socket_set_buffers (sock->sd, &sock->socket_buffer_sizes); +socket_set_buffers (sock->sd, &sock->socket_buffer_sizes, true);/* set socket to --mark packets with given value */ socket_set_mark (sock->sd, sock->mark);
src/openvpn/socket.h +12 -0
@@ -157,6 +157,18 @@int sndbuf; }; +/** +* Sets the receive and send buffer sizes of a socket descriptor. +* +* @param fd The socket to modify +* @param sbs new sizes. +* @param reduce_size apply the new size even if smaller than current one +*/ +void +socket_set_buffers (socket_descriptor_t fd, +const struct socket_buffer_size *sbs, +bool reduce_size); +/* * This is the main socket structure used by OpenVPN. The SOCKET_ * defines try to abstract away our implementation differences between
src/openvpn/tun_afunix.c +8 -0
@@ -35,6 +35,7 @@#include "wfp_block.h" #include "argv.h" #include "options.h" +#include "socket.h" #if defined(AF_UNIX ) && !defined(WIN32 )/* Windows does implement some AF_UNIX functionality but key features
@@ -80,6 +81,13 @@return ; } + +/* Ensure that the buffer sizes are decently sized. Otherwise macOS will +* just have 2048 */ +struct socket_buffer_size newsizes = {65536 ,65536 }; +socket_set_buffers (fds[0 ], &newsizes, false); +socket_set_buffers (fds[1 ], &newsizes, false); +/* Use the first file descriptor for our side and avoid passing it * to the child */ tt->fd = fds[1 ];
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/754?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ice015df81543c01094479929f0cb3075ca4f3813
Gerrit-Change-Number: 754
Gerrit-PatchSet: 1
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-MessageType: newchange
Attention is currently required from: flichtenheld, plaisthos.
cron2 has posted comments on this change. ( http://gerrit.openvpn.net/c/openvpn/+/754?usp=email )
Change subject: Ensure that the AF_UNIX socket pair has at least 65k of buffer space
......................................................................
Patch Set 2: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/754?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ice015df81543c01094479929f0cb3075ca4f3813
Gerrit-Change-Number: 754
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]...>
Gerrit-Attention: flichtenheld <[email protected]...>
Gerrit-Comment-Date: Wed, 25 Sep 2024 06:29:54 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
Gerrit-MessageType: comment
PATCH v2 1/1 Ensure that the AF_UNIX socket pair has at least 65k of buffer space
In reply to a message not in the archiveFrom: Arne Schwabe <[email protected]...>
Without this change, pinging a lwipovpn client with something like a 3000 byte payload on macOS often fails as the default buffer sizes on macOS are 2048 for send and 4096 for receive.
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/754
This mail reflects revision 2 of this Change.
Acked-by according to Gerrit (reflected above):
Gert Doering <[email protected]...>
src/openvpn/socket.c +9 -6
@@ -890,20 +890,23 @@#endif } -static void -socket_set_buffers (socket_descriptor_t fd,const struct socket_buffer_size *sbs) +void +socket_set_buffers (socket_descriptor_t fd,const struct socket_buffer_size *sbs, +bool reduce_size) {if (sbs) {const int sndbuf_old =socket_get_sndbuf (fd);const int rcvbuf_old =socket_get_rcvbuf (fd); -if (sbs->sndbuf) +if (sbs->sndbuf + && (reduce_size || sndbuf_old < sbs->sndbuf)) {socket_set_sndbuf (fd, sbs->sndbuf); } -if (sbs->rcvbuf) +if (sbs->rcvbuf + && (reduce_size || rcvbuf_old < sbs->rcvbuf)) {socket_set_rcvbuf (fd, sbs->rcvbuf); }
@@ -986,7 +989,7 @@ { ls->socket_buffer_sizes.sndbuf = sndbuf; ls->socket_buffer_sizes.rcvbuf = rcvbuf; -socket_set_buffers (ls->sd, &ls->socket_buffer_sizes); +socket_set_buffers (ls->sd, &ls->socket_buffer_sizes, true); } }
@@ -1136,7 +1139,7 @@ sock->info.af = addr->ai_family;/* set socket buffers based on --sndbuf and --rcvbuf options */ -socket_set_buffers (sock->sd, &sock->socket_buffer_sizes); +socket_set_buffers (sock->sd, &sock->socket_buffer_sizes, true);/* set socket to --mark packets with given value */ socket_set_mark (sock->sd, sock->mark);
src/openvpn/socket.h +12 -0
@@ -157,6 +157,18 @@int sndbuf; }; +/** +* Sets the receive and send buffer sizes of a socket descriptor. +* +* @param fd The socket to modify +* @param sbs new sizes. +* @param reduce_size apply the new size even if smaller than current one +*/ +void +socket_set_buffers (socket_descriptor_t fd, +const struct socket_buffer_size *sbs, +bool reduce_size); +/* * This is the main socket structure used by OpenVPN. The SOCKET_ * defines try to abstract away our implementation differences between
src/openvpn/tun_afunix.c +8 -0
@@ -35,6 +35,7 @@#include "wfp_block.h" #include "argv.h" #include "options.h" +#include "socket.h" #ifndef WIN32 /* Windows does implement some AF_UNIX functionality but key features
@@ -80,6 +81,13 @@return ; } + +/* Ensure that the buffer sizes are decently sized. Otherwise macOS will +* just have 2048 */ +struct socket_buffer_size newsizes = {65536 ,65536 }; +socket_set_buffers (fds[0 ], &newsizes, false); +socket_set_buffers (fds[1 ], &newsizes, false); +/* Use the first file descriptor for our side and avoid passing it * to the child */ tt->fd = fds[1 ];
[Openvpn-devel] [PATCH applied] Re: Ensure that the AF_UNIX socket pair has at least 65k of buffer space
The interesting part in this is the change to socket_set_buffers(), introducing an "increase only" flag to avoid accidentially reducing socket buffers (which happens when people use --sndbuf with a smaller buffer size than the socket already has...) - sndbuf/rcvbuf behaviour is not change, but for the newly created socketpair(), this is "increase to 64k, or leave at already-larger value"...
Sanity check via a local FreeBSD test run (with lwipovpn) and a GHA run.
Your patch has been applied to the master branch.
commit bae48c1d58d5592ffecca8a490c2440ec3afe959
Author: Arne Schwabe Date: Wed Sep 25 08:30:16 2024 +0200
Ensure that the AF_UNIX socket pair has at least 65k of buffer space
Signed-off-by: Arne Schwabe <[email protected]...>
Acked-by: Gert Doering <[email protected]...>
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg29413.html
Signed-off-by: Gert Doering <[email protected]...>--
kind regards,
Gert Doering
cron2 has uploaded a new patch set (#3) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/754?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by cron2
Change subject: Ensure that the AF_UNIX socket pair has at least 65k of buffer space
......................................................................
Ensure that the AF_UNIX socket pair has at least 65k of buffer space
Without this change, pinging a lwipovpn client with something like a 3000 byte payload on macOS often fails as the default buffer sizes on macOS are 2048 for send and 4096 for receive.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg29413.html
---
M src/openvpn/socket.c
M src/openvpn/socket.h
M src/openvpn/tun_afunix.c
3 files changed, 29 insertions(+), 6 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/54/754/3
src/openvpn/socket.c +9 -6
@@ -890,20 +890,23 @@#endif } -static void -socket_set_buffers (socket_descriptor_t fd,const struct socket_buffer_size *sbs) +void +socket_set_buffers (socket_descriptor_t fd,const struct socket_buffer_size *sbs, +bool reduce_size) {if (sbs) {const int sndbuf_old =socket_get_sndbuf (fd);const int rcvbuf_old =socket_get_rcvbuf (fd); -if (sbs->sndbuf) +if (sbs->sndbuf + && (reduce_size || sndbuf_old < sbs->sndbuf)) {socket_set_sndbuf (fd, sbs->sndbuf); } -if (sbs->rcvbuf) +if (sbs->rcvbuf + && (reduce_size || rcvbuf_old < sbs->rcvbuf)) {socket_set_rcvbuf (fd, sbs->rcvbuf); }
@@ -986,7 +989,7 @@ { ls->socket_buffer_sizes.sndbuf = sndbuf; ls->socket_buffer_sizes.rcvbuf = rcvbuf; -socket_set_buffers (ls->sd, &ls->socket_buffer_sizes); +socket_set_buffers (ls->sd, &ls->socket_buffer_sizes, true); } }
@@ -1136,7 +1139,7 @@ sock->info.af = addr->ai_family;/* set socket buffers based on --sndbuf and --rcvbuf options */ -socket_set_buffers (sock->sd, &sock->socket_buffer_sizes); +socket_set_buffers (sock->sd, &sock->socket_buffer_sizes, true);/* set socket to --mark packets with given value */ socket_set_mark (sock->sd, sock->mark);
src/openvpn/socket.h +12 -0
@@ -157,6 +157,18 @@int sndbuf; }; +/** +* Sets the receive and send buffer sizes of a socket descriptor. +* +* @param fd The socket to modify +* @param sbs new sizes. +* @param reduce_size apply the new size even if smaller than current one +*/ +void +socket_set_buffers (socket_descriptor_t fd, +const struct socket_buffer_size *sbs, +bool reduce_size); +/* * This is the main socket structure used by OpenVPN. The SOCKET_ * defines try to abstract away our implementation differences between
src/openvpn/tun_afunix.c +8 -0
@@ -35,6 +35,7 @@#include "wfp_block.h" #include "argv.h" #include "options.h" +#include "socket.h" #ifndef WIN32 /* Windows does implement some AF_UNIX functionality but key features
@@ -80,6 +81,13 @@return ; } + +/* Ensure that the buffer sizes are decently sized. Otherwise macOS will +* just have 2048 */ +struct socket_buffer_size newsizes = {65536 ,65536 }; +socket_set_buffers (fds[0 ], &newsizes, false); +socket_set_buffers (fds[1 ], &newsizes, false); +/* Use the first file descriptor for our side and avoid passing it * to the child */ tt->fd = fds[1 ];
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/754?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ice015df81543c01094479929f0cb3075ca4f3813
Gerrit-Change-Number: 754
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: newpatchset
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/754?usp=email )
Change subject: Ensure that the AF_UNIX socket pair has at least 65k of buffer space
......................................................................
Ensure that the AF_UNIX socket pair has at least 65k of buffer space
Without this change, pinging a lwipovpn client with something like a 3000 byte payload on macOS often fails as the default buffer sizes on macOS are 2048 for send and 4096 for receive.
Message-Id: <[email protected]...>
URL: https://www.mail-archive.com/[email protected]/msg29413.html
---
M src/openvpn/socket.c
M src/openvpn/socket.h
M src/openvpn/tun_afunix.c
3 files changed, 29 insertions(+), 6 deletions(-)
src/openvpn/socket.c +9 -6
@@ -890,20 +890,23 @@#endif } -static void -socket_set_buffers (socket_descriptor_t fd,const struct socket_buffer_size *sbs) +void +socket_set_buffers (socket_descriptor_t fd,const struct socket_buffer_size *sbs, +bool reduce_size) {if (sbs) {const int sndbuf_old =socket_get_sndbuf (fd);const int rcvbuf_old =socket_get_rcvbuf (fd); -if (sbs->sndbuf) +if (sbs->sndbuf + && (reduce_size || sndbuf_old < sbs->sndbuf)) {socket_set_sndbuf (fd, sbs->sndbuf); } -if (sbs->rcvbuf) +if (sbs->rcvbuf + && (reduce_size || rcvbuf_old < sbs->rcvbuf)) {socket_set_rcvbuf (fd, sbs->rcvbuf); }
@@ -986,7 +989,7 @@ { ls->socket_buffer_sizes.sndbuf = sndbuf; ls->socket_buffer_sizes.rcvbuf = rcvbuf; -socket_set_buffers (ls->sd, &ls->socket_buffer_sizes); +socket_set_buffers (ls->sd, &ls->socket_buffer_sizes, true); } }
@@ -1136,7 +1139,7 @@ sock->info.af = addr->ai_family;/* set socket buffers based on --sndbuf and --rcvbuf options */ -socket_set_buffers (sock->sd, &sock->socket_buffer_sizes); +socket_set_buffers (sock->sd, &sock->socket_buffer_sizes, true);/* set socket to --mark packets with given value */ socket_set_mark (sock->sd, sock->mark);
src/openvpn/socket.h +12 -0
@@ -157,6 +157,18 @@int sndbuf; }; +/** +* Sets the receive and send buffer sizes of a socket descriptor. +* +* @param fd The socket to modify +* @param sbs new sizes. +* @param reduce_size apply the new size even if smaller than current one +*/ +void +socket_set_buffers (socket_descriptor_t fd, +const struct socket_buffer_size *sbs, +bool reduce_size); +/* * This is the main socket structure used by OpenVPN. The SOCKET_ * defines try to abstract away our implementation differences between
src/openvpn/tun_afunix.c +8 -0
@@ -35,6 +35,7 @@#include "wfp_block.h" #include "argv.h" #include "options.h" +#include "socket.h" #ifndef WIN32 /* Windows does implement some AF_UNIX functionality but key features
@@ -80,6 +81,13 @@return ; } + +/* Ensure that the buffer sizes are decently sized. Otherwise macOS will +* just have 2048 */ +struct socket_buffer_size newsizes = {65536 ,65536 }; +socket_set_buffers (fds[0 ], &newsizes, false); +socket_set_buffers (fds[1 ], &newsizes, false); +/* Use the first file descriptor for our side and avoid passing it * to the child */ tt->fd = fds[1 ];
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/754?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: Ice015df81543c01094479929f0cb3075ca4f3813
Gerrit-Change-Number: 754
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]...>
Gerrit-Reviewer: cron2 <[email protected]...>
Gerrit-Reviewer: flichtenheld <[email protected]...>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-MessageType: merged